# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer:
pkgname=nvi
pkgver=1.81.6
pkgrel=3
pkgdesc="Re-implementation of the vi editor"
url="http://www.bostic.com/vi"
arch="all"
license="BSD-3-Clause"
makedepends="db-dev ncurses-dev"
subpackages="$pkgname-doc $pkgname-catalog::noarch"
source="http://ftp.debian.org/debian/pool/main/n/nvi/nvi_$pkgver.orig.tar.gz
	01additional_upstream_data.patch
	03db4.patch
	04confdefs.patch
	06default_value_escapetime.patch
	07flush_cache.patch
	08lfs.patch
	08safe_printf.patch
	08tempfile_umask.patch
	09casting.patch
	10no_one_line_visual.patch
	11backward_sentence_moving.patch
	12horiz_scroll_count.patch
	13widechar_horrors.patch
	14private_regex_fixes.patch
	15search_word.patch
	16manpage_errors.patch
	17tutorial_typos.patch
	18dbpagesize_binpower.patch
	19include_term_h.patch
	21exrc_writability_check.patch
	24fallback_to_dumb_term.patch
	25manpage_note_dropped_F.patch
	26trailing_tab_segv.patch
	27support_C_locale.patch
	29file_backup.patch"

prepare() {
	default_prepare
	update_config_sub
}

build() {
	cd "$builddir"/dist
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--program-prefix=n \
		--enable-widechar \
		--disable-threads
	make
}

package() {
	mkdir -p "$pkgdir"/usr/bin
	make -j1 PREFIX=/usr DESTDIR="$pkgdir" \
		install -C "$builddir"/dist

	# Remove tcl and perl scripts.
	rm -rf "$pkgdir"/usr/share/vi/tcl
	rm -rf "$pkgdir"/usr/share/vi/perl

	# Remove cat man pages.
	rm -rf "$pkgdir"/usr/share/man/cat1

	# Remove library.
	rm -f "$pkgdir"/usr/lib/libvi.a
}

catalog() {
	depends=""
	pkgdesc="$pkgdesc (catalog files)"

	mkdir -p "$subpkgdir"/usr/share/vi/
	mv "$pkgdir"/usr/share/vi/catalog/ \
		"$subpkgdir"/usr/share/vi/
}

sha512sums="1be798daf0cd05010ddaf0aa0510dc799708fd79d4b243e2700adff18e931ddd9d11621796fa8086088c3e93ba20f15ab86783732665169c52b73eaf587ff0b3  nvi_1.81.6.orig.tar.gz
ec998baba23d15c957dbdb121a4ba7eddf0aac15503e381a1318a7e7127b0c06f3bd05ebd474175f39a6fb050ed6fd3a1f4bd348d92770355e8bc3d8d37277c9  01additional_upstream_data.patch
d635c86c52cf16ccc947ee8a4593160adf183b236ae7c2eb03ff2ea628f493e484f906b762eb1d90ec1febc48119cac955382af3ebc223e29622123500a45f97  03db4.patch
9b45e0639a30b81204e1c9b43877a6a83df2a5bba3b85a410427ead1e639cc9882f0ca162721074782870742af449c5a3f00b5051d459491bf9afb7cd718450d  04confdefs.patch
4820b584614d321b6528b9400429440b126c5c8ccc502f9e61ec7ff9cd7769e7c53e04f83ffcd4804c6baed5ac55953834644444c11e9cf42841e8fb371196ca  06default_value_escapetime.patch
df74b0977e7d864e7ea9833404f818cfb644c9fa188024b6174c7a2360350cc63f8cd8cd7fc19e54dbc5db8e2b6310be9807bb7bd108ab56dbc2d3d9cf8bff14  07flush_cache.patch
0a432a0823d0d0b2bba2dba6ee24f1b173b4552245c1bba1727804dfa8eff09dfd88129fb615eae5846aa6ef929c08a0a23a505b000dc77ecc6de578d3dc8026  08lfs.patch
2c1afb271f60031a15d4e2093b4e04c02462cc1d1815ce557049364bcdc81f83d3c6e25766a7a7efa8d04cc1c8284e9684df12ab161aba16bb479c9ee4660012  08safe_printf.patch
af723124cef36966c57785f9066cc924d155a0d495375849db36a1bf1ef1b166afd8f057d258ada9367fbf82cd30694efeeeb246d0fb14ff07fcdb807230e109  08tempfile_umask.patch
e70ee763a5c54424f75143ce892b93d8046618935bdc50bc3e646848b9b0f3d4bacf0a362b4203984527dbd98ea321a12b81b69eee7aa340e745b5d77492aca0  09casting.patch
65776b87d86cde21ef8034a1c1fe88daaac03a960223a05fdb2e1005b7e44348dc4571abe0addeef65f08fbeef72fb376486b3dccaaff4cc7d4c39bdc206026d  10no_one_line_visual.patch
f99afc8f83ea84ce059dbd5dc7b1bf726dbb2c64de8b12a7de21ca42a76e0a3b9f19d0c8c73bd046d7e0ad5ae81afed7f8e472232bcc55eb221b479ab4671f48  11backward_sentence_moving.patch
3f77c69d08d8c807eb62332eca84af898849214660e238915cadf60e46014295889bb4c66fc116846d1d9cdc2cd4d3b89b4c9c4c6a5e908ebd530f6b9fee00f0  12horiz_scroll_count.patch
97e403723934bf634120e53b7d629ca87dbae73ed0a736cf2c15d4d3f7432792535a106fbf5eb959d3b1706a868d79bf24f450e24c9b2fe295df9443ef017504  13widechar_horrors.patch
e5b1c0d7d7f96a2066f637f848564877920f163c715a1b2c4248298ed0b6a420fd3fe4e61c3925c48bd96168352cb3935b713abff8cb33d069362192f99047d7  14private_regex_fixes.patch
eadc89e64b93043dfcf8493ff8a36bc7c2f147c313a958a68edbea577cef92d10f9f2262dbb464016e4008e232a6efdb83cc0b3469cdc75b49eab7419a9ef01e  15search_word.patch
21ab846548101d58d1d9d2a93c6f309729dfdc3df33a0dd73bf55d30fc42314e4dabdeb605178a6bd256ecdab4f4331e3c156b1071c0bbf82046acb40434b7ce  16manpage_errors.patch
2dfc294f98302afad67095c8376de4de3bd582f890151ba495d1c4212964c360a9fc2afc7d988be0715b4e5d498c99f228f01d516ad57435baf07993c21c13a1  17tutorial_typos.patch
4d8999b235634fc040d45036624d880ed3c6be614cd52c7f642f8144d24726ad764a71e385445c6346f101f65febe3e609e9c9452744ee4cef5774f9048f0029  18dbpagesize_binpower.patch
27be473dc1628c407963eb4c828caa8c41ad57abb75ddf9adefe7a065ce9f8cfe16536aabeb1f078f859fa7a8817ea8d5d2ca1cb36c47be27436a9789faeb504  19include_term_h.patch
4065b814649cbbc57535941b4f20ceacc925b0ef6decfbaa5a60c6c4b943f2a5b6c68371fa87f8dce5b6c219740a10339948ffdce226c88509a807580e19864d  21exrc_writability_check.patch
b0a4c9ba713d8fb8fa8559b6038bcb70d0fb6e411a3a73cf677c38d8288f28a2febfa92f387aef899ac3959fb7bdf5220334e025b71260157f935b0f79f01e66  24fallback_to_dumb_term.patch
9a6a71574c3fb6073d3fdd0abf783f0053fbfb1ee8408e208c9368a72c3b25a5f56156da50bdd06ebf381210278c91036cca29333b48a0d5f432bbaa1d82bbd5  25manpage_note_dropped_F.patch
89ae70a8a2dd4fbb51e1f6e570f958e7dc63e4f60076446f5f0ce063f4dac19d2d1c8da241b4a709ef028459e4b43c682f1a3021ef4f04a72be98b7e2c7b9fd1  26trailing_tab_segv.patch
c091a870efc7181b3480998b8b8427cdec4b37ef66358ae8bfd2c79d6037c9b64fd6e004e39400680d1d67f608c35d56e7e36d91810ded04f984fe89a052925a  27support_C_locale.patch
4c050c5d8ee298f88bc59fd7282739dfe9202610285ca64c59b579698667ac6c8940ecf91b2b3df34d31a8ee818b9c18b1a4f9a0b47894dd4c6f8bd20c9f1c75  29file_backup.patch"
